import './404.scss'
import {useState,useEffect, useRef} from 'react'
import {useNavigate} from 'react-router-dom'
import { Button } from 'antd-mobile'
export const NotFound = ()=>{
    let [times,settimes] = useState(5);
    const tiem = useRef<HTMLDivElement>({} as HTMLDivElement)
    // const tiem = useRef<HTMLDivElement>() //括号不写内容 认为是undefined
    const router = useNavigate();
    let time:NodeJS.Timeout;
    const setDate = ()=>{
        time = setInterval(()=>{
            console.log(tiem);
            
            if(times>0){
                settimes(times--)
                console.log(times);
                
            }else{
                clearInterval(time);
                router('/homes')
            }
        },1000)
    }

    useEffect(()=>{
        setDate();
        console.log('kkkk');
        
        return ()=>clearInterval(time)
    },[])
    return(
        <div className="errorpage" ref={tiem}>
            <div className='tiaozhuan'>{times}秒自动跳转</div>
        </div>
    )
}